#include<bits/stdc++.h>
using namespace std;
struct node
{
    int d;
    int v;
    int a;
}b[100010];
int p[100010];
bool vis[100010];
bool cmp1(int x,int y)
{
    return x<y;
}
int main()
{
   freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin>>t;
    while(t--)
    {
        int n,m,L,V;
        int ans=0,s=0;
        bool f=0;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=m;i++)
            {
                vis[i]=false;
            }
        for(int i=1;i<=n;i++)
        {
            cin>>b[i].d>>b[i].v>>b[i].a;
            if(b[i].a<0)
            {
                f=1;
            }
        }
        for(int i=1;i<=m;i++)
        {
            cin>>p[i];
        }
        sort(p+1,p+1+m,cmp1);
        for(int i=1;i<=n;i++)
        {
            if(b[i].a==0)
            {
                if(b[i].v<=V)
                {
                    continue;
                }
                else
                {
                   if(b[i].d<p[m])
                   {
                       ans++;
                   }
                }
            }
            if(b[i].a>0)
            {
                if(b[i].v>V)
                {
                   if(b[i].d<=p[m])
                   {
                       ans++;
                   }
                }
                else
                {
                    double s1=b[i].d+(V*V-b[i].v*b[i].v)/(2*b[i].a);
                    if(s1<=p[m])
                    {
                        ans++;
                    }
                }
            }
            if(b[i].a<0)
            {
                if(b[i].v<=V)
                {
                    continue;
                }
                else
                {
                    double s1=b[i].d+(V*V-b[i].v*b[i].v)/(2*b[i].a);
                    int k;
                    for(int j=1;j<=m;j++)
                    {
                        if(p[j]>=b[i].d)
                        {
                           k=j;
                           break;
                        }
                    }
                    if(s1>=p[k])
                    {
                       int v1=sqrt(b[i].v*b[i].v+2*b[i].a*(p[k]-b[i].d));
                       if(v1>V)
                       {
                           ans++;
                           vis[k]=true;
                       }
                    }
                }

            }
        }
        cout<<ans<<" ";
        if(f==0)
        {
            s=m-1;
            cout<<s<<endl;
        }
        else
        {
            for(int i=1;i<=m;i++)
            {
                if(vis[i]==true)
                {
                    s++;
                }
            }
            s=m-s;
            cout<<s<<endl;
        }
    }
   return 0;
}
